<template>
  <div class="common-page f-c">
    <BackPage title="事项管理" />
    <div class="search-params f-r a-c j-b">
      <el-form inline label-width="110px">
        <el-form-item label="名称：">
          <el-input v-model="searchParams.productName" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" round @click="onSearch">筛选</el-button>
          <el-button round @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="f-r j-e">
      <el-form>
        <el-form-item>
          <div class="f-r a-c">
            <el-button type="primary" round @click="onAdd">新增</el-button>
          </div>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-box f-g">
      <el-table
        v-loading="loading"
        height="100%"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column type="index" width="80px" label="序号" align="center" />
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="操作" fixed="right" width="120px">
          <template slot-scope="scope">
            <el-button type="text" @click="onEdit(scope.row)">编辑</el-button>
            <el-button type="text" @click="onDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <ItemAdd ref="ItemAddRef" @get-page="initData" />
  </div>
</template>

<script>
import crud from '@/mixins/crud'
import ItemAdd from './add'
import { http_product } from '@/api'
export default {
  name: 'Index',
  components: {
    ItemAdd
  },
  mixins: [crud],
  data() {
    return {
      request: http_product,
      searchParams: {
      },
      columns: [
        { prop: 'productName', label: '事项名称' },
        { prop: 'productCode', label: '事项编码' },
        { prop: 'createTime', label: '创建时间' }
      ],
      tableData: [],
      deleteKey: 'productCode'
    }
  },
  methods: {
    formatTableData(data) {
      data.forEach(el => {

      })
    },
    onAdd() {
      this.$refs.ItemAddRef.open()
    },
    onEdit(item) {
      this.$refs.ItemAddRef.open(item)
    },
    onRead() {}
  }
}
</script>
